package com.test.mina2.example.message;

import java.nio.charset.Charset;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

// 4编 解 码工厂
public class CmccSpicCodecFactory implements ProtocolCodecFactory {

	private final CmccSpicEncoder encoder;
	private final CmccSpicDecoder decoder;

	public CmccSpicCodecFactory() {
		this(Charset.defaultCharset());
	}

	public CmccSpicCodecFactory(Charset charset) {
		this.encoder = new CmccSpicEncoder(charset);
		this.decoder = new CmccSpicDecoder(charset);

	}

	@Override
	public ProtocolEncoder getEncoder(IoSession session) throws Exception {
		return encoder;
	}

	@Override
	public ProtocolDecoder getDecoder(IoSession session) throws Exception {
		return decoder;
	}

}
